/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.blog.wordpress.sessionbeans;

import com.blog.wordpress.entities.Article;
import java.util.Collection;
import java.util.List;
import javax.ejb.Stateless;
import javax.management.Query;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Breath
 */
@Stateless
public class ArticleFacade extends AbstractFacade<Article> implements ArticleFacadeLocal {

    @PersistenceContext(unitName = "com.blog_WordPress_wa")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public ArticleFacade() {
        super(Article.class);
    }

    public List<Article> findLast5Comments() {
        List<Article> lastArticles = (List<Article>) this.getEntityManager().createQuery("SELECT TOP 5 * FROM Article a").setMaxResults(5);
        return lastArticles;
    }
}
